{% comment %}
#    This file is part of OpenPolitik.
#
#    OpenPolitik is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    OpenPolitik is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with OpenPolitik.  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}
{% extends "layout.html" %}

{% block content %}
<script type = "text/javascript">
function validate(){
	var err = false;
	$("err_msg").innerHTML = "";
	if ($("content").innerHTML.match(/^\s*$/)){
		err = true;
		$("err_msg").innerHTML += "You must enter some content.";
	}

	if ($("subject").value.match(/^\s*$/)){
		err = !confirm("Send with no subject?");
	}

	return !err;
}
</script>
<form action = "" method = "post" onsubmit = "return validate()">
	<p class = "last"><label>To:</label> {{ to.nickname }}{% if nation %} ( {{ nation }} ){% endif %}</p>
	<p class = "last"><label>Subject:</label><input id = "subject" name = "subject" maxlength = "64" /></p>
	<p class = "last"><label>Message:</label><textarea id = "content" name = "content" rows = "10" cols = "60"></textarea></p>
	<p class = "last"><label>&nbsp;</label><input type = "submit" value = "Send" /></p>
	<span id = "err_msg"></span>
</form>
<a href = "/game?game={{ game.key }}">Back to {{ game.name }}</a>
{% endblock %}
